package icu.xuyijie.springbootlearning1.chapter8;

import org.springframework.boot.actuate.health.AbstractHealthIndicator;
import org.springframework.boot.actuate.health.Health;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author 徐一杰
 * @date 2025/03/14 13:52
 * @description
 */
@Component
public class MyHealthInfo extends AbstractHealthIndicator {
    private Integer index = 0;

    @Override
    protected void doHealthCheck(Health.Builder builder) throws Exception {
        if (index == 1) {
            builder.up().withDetails(Map.of("why", "index等于1"));
        } else {
            builder.down().withDetails(Map.of("why", "因为index不等于1", "author", "徐一杰"));
        }
    }
}
